package com.zhiyou100.pra;

/**
 * 出租车计费
 */
public class TaxiCount {
    //起步价   静态   被所有对象共享
    private static double initiateFare = 8;

    public static double getInitiateFare() {
        return initiateFare;
    }

    public static void setInitiateFare(double initiateFare) {
        initiateFare = initiateFare;
    }

    /**
     * 出租车计算
     * @param distance 里程数
     */
    public void countFare(double distance) {
        if (distance <= 2) {
            System.out.println("费用为:" + initiateFare);
        } else {
            System.out.println("费用为:" + (initiateFare + (distance - 2) * 1.5));
        }
    }

    public static void main(String[] args) {
        TaxiCount taxi = new TaxiCount();
        taxi.countFare(10);
    }

}

